package com.example.lib_storage.utils

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken

object GSON {
    val gson :Gson by lazy {
        GsonBuilder().serializeNulls().disableHtmlEscaping().create()
    }
    fun toJson(source:Any?):String{
        return gson.toJson(source)
    }
    inline fun <reified T> fromJson(json:String):T?{
        return gson.fromJson(json,object :  TypeToken<T>() {}.type)
    }
    fun <T> fromJson(json:String,clazz:Class<T>):T{
        return gson.fromJson(json,clazz)
    }
}